<?php

	require_once ('application/extra/db.php');

	$details = array (
								'hostname' => 'localhost',
								'database' => 'ronl',
								'username' => 'ronl',
								'password' => 'moncholo',
								'port'     => 3360
				);
	
	$db = new fluxMySql ($details);

	$db->setFileDebugging(TRUE);
	$db->setExceptions(TRUE);
	//$insert->setAutoFilter (FALSE);

	/*
	$genre = $db->select ('*');
	$genre->from('genres');

	$paises = $db->select (array('id_pais'=>'idPais'),'nombre_pais');
	$paises->from  ('paises');
	$paises->where ();
	$paises->like  ('nombre_pais','*Ar*');
	$paises->limit (2,3);
	$paises->order (array('nombre_pais','id_pais'),'ASC');
	$paises->in ($genre,'w');
	$paises->group  ('x');
	$paises->having ();
	$paises->having->and ('id_pais','>=',1);
	echo $paises."\n";
	echo $having;

	*/

	//Return an array of stdClass objects, each one of these objects
	//Contains the fields of the given table as properties
	//For instance: Taking the above example one could do this:
	//
	//foreach ($paises->getObject() as $k=>$paisesTable)
	//echo $paisesTable -> idPais . '=>' . $paisesTable->nombre_pais . "\n";  
	//Remember we are using id_pais AS idPais
	//
	//If you Like arrays more than objects then you could do this:
	//foreach ($paises->getObject() as $k=>$paisesTable)
	//	echo $paisesTable['idPais']; //Remember we are using id_pais AS idPais

	//Hardcore ?	
	//$recurso = $paises->getResource();
	//var_dump ($recurso);

	//Using IN
	//$pcias = $db->select (array('id_provincia'=>'idPro','id_pais'=>'idPa'));
	//$pcias->from  ('provincias');
	//$pcias->where ('idPa');
	//$pcias->in ($paises);
	//var_dump($pcias->getObject());
	//

	//Doing an insert

	$insert = $db->insert('paises');
	$insert->values (array('nombre_pais'=>"Porongolandia"));
	$insert->execute();

	//Or this 

	$insert->values (array('campo'=>'valor','campo2'=>'valor2'));
	$insert->values (array('lista'=>'x','de','cosas','a','insertar'));

	$insert->dumpTable();
	$insert->dumpValues();
	die ();

/*
	$paises = $db->select ('*');
	$paises->from  ('alguna_tabla');
	$paises->where ('!a','>=','b'); //Using NOT
	$paises->and   ('z','>');
	$paises->in ('w',$genres);
	echo "\n".$paises . "\n";
	die ();
*/


/*
	foreach ($db->showTables() as $k => $v){
				$l = 'select_' .$v->Tables_in_ronl;
				$z = call_user_func(array($db,$l));
				foreach ($z as $key=>$obj)
						  echo $obj->nombre_pais;
				
	}
	 */

?>
